package com.liang.demo.base;

import com.liang.demo.po.Admin;
import com.liang.demo.util.JwtUtil;
import com.liang.demo.util.ModelMapperSingle;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;
import org.modelmapper.ModelMapper;

/**
 * @author 陈琪亮
 * @version 1.0
 * @date 2021/3/18 15:19
 */
public class BaseApiController {

    //默认分页大小
    protected final static String DEFAULT_PAGE_SIZE = "10";

    //转换对象（用来代替BeanUtils）
    protected final static ModelMapper modelMapper = ModelMapperSingle.Instance();

    //获取当前登录对象
    protected Long getCurrentUser() {
        Subject subject = SecurityUtils.getSubject();
        String token = (String) subject.getPrincipal();
        String adminId = JwtUtil.getDate(token);
        return Long.parseLong(adminId);
    }
}
